package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.LineInfo;

import static org.apache.commons.lang3.StringUtils.trimToEmpty;

/**
 * 签条或者字面文本的界面模型。
 */
public class LabelModel
        extends AbstractComponentModel
        implements ComponentModel {
    private final String text;
    private final char mnemonic;
    private final String forName;
    private final boolean html;
    private final ModelAlignment alignment;

    /**
     * 构造解析对象。
     *
     * @param lineInfo
     *         源文件中的位置信息。
     */
    protected LabelModel(
            LineInfo lineInfo,
            String name,
            boolean visible,
            String text,
            char mnemonic,
            String forName,
            boolean html,
            ModelAlignment alignment
    ) {
        super(lineInfo, name, visible);
        this.text = text != null ? text : "";
        this.mnemonic = mnemonic;
        this.forName = trimToEmpty(forName);
        this.html = html;
        this.alignment = alignment;
    }

    public final String getText() {
        return this.text;
    }

    public final char getMnemonic() {
        return mnemonic;
    }

    public final String getForName() {
        return this.forName;
    }

    public final boolean isHtml() {
        return this.html;
    }

    public final ModelAlignment getAlignment() {
        return this.alignment;
    }
}
